package com.jiangxjsy.crm.support;

import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Component;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/19 16:31
 */

@Component
public class CrmFieldSortSupport {
    /**
     * 解析字段名称
     *
     * @param fieldName 字段名称
     * @return 字段名称
     */
    public String parseFieldName(String fieldName) {
        if ("contract_id".equals(fieldName)) {
            return "contractNum";
        }
        if ("receivables_plan_id".equals(fieldName)){
            return "planNum";
        }
        if (fieldName.endsWith("_id")) {
            fieldName = fieldName.substring(0, fieldName.lastIndexOf("_id")).concat("_name");
        }
        return StrUtil.toCamelCase(fieldName);
    }
}
